package com.example.ByteStream;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author Jason
 * @PACKAGE_NAME com.example.ByteStream
 * @Description 复制文件
 * @date 2023-12-11 15:59
 */
public class FileInOutDemo {
    public static void main(String[] args) throws IOException {
        //创建流
        //文件字节输入流
        FileInputStream fis = new FileInputStream("d:\\aaaa.jpg");
        //文件字节输出流
        FileOutputStream fos = new FileOutputStream("d:\\bbbb.jpg", true);
        //一边读取流一边写入流
        byte[] buf = new byte[1024];
        int count = 0;
        while ((count = fis.read(buf)) != -1) {
            fos.write(buf, 0, count);
        }
        //关闭
        fis.close();
        fos.close();
        System.out.println("复制完毕");

    }
}
